package com.dong.common.base.controller;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: dj
 * Date: 2017/11/4
 * Time: 11:30
 */
public class BaseType extends HashMap<String,Object>{

    public static final String TYPE_ERROR = "error";
    public static final String TYPE_SUCCESS = "success";
    public static final String TYPE_ZERO = "0";

    private String type;

    private String msg;

    public String getType() {
        return this.get("type").toString();
    }

    public String getMsg() {
        return this.get("msg").toString();
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static BaseType error(String msg) {
        BaseType r = new BaseType();
        r.put("msg", msg);
        r.put("type", TYPE_ERROR);
        return r;
    }

    public static BaseType success(String msg) {
        BaseType r = new BaseType();
        r.put("msg", msg);
        r.put("type", TYPE_SUCCESS);
        return r;
    }

    public static BaseType success() {
        BaseType r = new BaseType();
        r.put("type", TYPE_SUCCESS);
        return r;
    }

    @Override
    public BaseType put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
